package com.syf.service;

import com.syf.domain.Account;
import com.baomidou.mybatisplus.extension.service.IService;
import com.syf.vo.SymbolAssetVo;
import com.syf.vo.UserTotalAccountVo;

import java.math.BigDecimal;

/**
*
*
*@author 苏耀奋
*@create 2021-10-12 18:48
*/
public interface AccountService extends IService<Account>{

    /**
     * 用户资金的划转
     * @param adminId
     * @param userId
     * @param coinId
     * @param orderNum
     * @param num
     * @param fee
     * @param remark
     * @param businessType
     * @param direction
     * @return
     */
    Boolean transferAccountAmount(Long adminId, Long userId, Long coinId, Long orderNum, BigDecimal num, BigDecimal fee, String remark, String businessType, Byte direction);

    /**
     * 用户资金的划转
     *
     * @param adminId
     * @param userId
     * @param coinId
     * @param num
     * @param fee
     * @return
     */
    Boolean decreaseAccountAmount(Long adminId, Long userId, Long coinId, Long orderNum, BigDecimal num, BigDecimal fee, String remark, String businessType, byte direction);

    /**
     * 通过用户Id、币种Id 查询用户的货币资产
     *
     * @param userId   用户的id
     * @param coinName 货币的名称
     * @return
     */
    Account findByUserAndCoin(Long userId, String coinName);

    /**
     * 暂时锁定用户的资产
     *
     * @param userId  用户的id
     * @param coinId  币种的id
     * @param mum     锁定的金额
     * @param type    资金流水的类型
     * @param orderId 订单的Id
     * @param fee
     */
    void lockUserAmount(Long userId, Long coinId, BigDecimal mum, String type, Long orderId, BigDecimal fee);

    /**
     * 计算用户的总的资产
     * @param userId
     * @return
     */
    UserTotalAccountVo getUserTotalAccount(Long userId);

    /**
     * 交易货币的资产【根据币种查询各自卖出/买入的数据(余额、单位)】
     * @param symbol
     * @param userId
     * @return
     */
    SymbolAssetVo getSymbolAssert(String symbol, Long userId);

    /**
     * 划转买入的账户余额
     * @param fromUserId
     * @param toUserId
     * @param coinId
     * @param amount
     * @param businessType
     * @param orderId
     */
    void transferBuyAmount(Long fromUserId, Long toUserId, Long coinId, BigDecimal amount, String businessType, Long orderId);

    /**
     * 划转出售的成功的账户余额
     * @param fromUserId
     * @param toUserId
     * @param coinId
     * @param amount
     * @param businessType
     * @param orderId
     */
    void transferSellAmount(Long fromUserId, Long toUserId, Long coinId, BigDecimal amount, String businessType, Long orderId);
}
